--[[
Project: HunterRP
File: cl_stamina.lua
Author: Cypher, Sebihunter
]]--
require("datastream")

stamina={}
staminaon = 0

function staminaFunc()
	if not stamina[LocalPlayer()] then stamina[LocalPlayer()] = 1000 end	
	local cmd = LocalPlayer():GetCurrentCommand()
	local localstamina = 0
	if cmd:KeyDown(IN_SPEED) or cmd:KeyDown(IN_JUMP) then
		if (stamina[LocalPlayer()] < 250) and (stamina[LocalPlayer()] > 0) then
			stamina[LocalPlayer()] = stamina[LocalPlayer()] - 3
			localstamina = 1
		elseif stamina[LocalPlayer()] > 0 then
			stamina[LocalPlayer()] = stamina[LocalPlayer()] - 3
		else
			localstamina = 1
		end
	else
		if stamina[LocalPlayer()] < 1000 then 
			stamina[LocalPlayer()] = stamina[LocalPlayer()] + 1
		end
	end
	
	if staminaon ~= localstamina then
		staminaon = localstamina
		if staminaon == 1 then
			datastream.StreamToServer( "setStaminaEffect", { ["iseffect"] = "1" } );
		else
			datastream.StreamToServer( "setStaminaEffect", { ["iseffect"] = "0" } );
		end
	end	
end
